//	获取url传值
	function getQueryString(name) {
		var result = window.location.search.match(new RegExp("[\?\&]" + name + "=([^\&]+)", "i"));
		if (result == null || result.length < 1) {return "";}
			return result[1];
	}
	pid = getQueryString("pid");
$(function(){
	$(".coll_body").eq(0).show();
	$(".coll_body").eq(0).children('a').eq(0).addClass("active");
	$(".Collapsing").eq(0).children('a').children('span').addClass("rotate");
	$(".Collapsing").eq(0).click(function(){
		$(".Collapsing").eq(0).toggleClass("active");
		$(this).children('.coll_body').children('a').eq(0).toggleClass("active");
	})
//	任务列表分页
	var pageSize = 5;
	var currentPage = 1; 
	ajaxTest(currentPage);
	function ajaxTest(currentPage) {
		$.ajax({ 
				type:"post",
				url:serverIP+"/user/mainTask/list",
				xhrFields:{
			        withCredentials: true    // 设置sessionId相同
			    },
				data: {page:currentPage,pId:pid},
				success:function(data){
				  let result = data.data.list.result;
                  var strVar = "";
                  result.map(function(u){
	                if(u.status == "01"){
	                    var status="未开始维护";
	                }else if(u.status == "02"){
	                    var status="正在维护中";
	                }else if(u.status == "03"){
	                    var status="维护完成";
	                }
                    if(u.grade == "01"){
                    	var grade="一级";
                    }else if(u.grade == "02"){
                    	var grade="二级";
                    }else if(u.grade == "03"){
                    	var grade="三级";
                    }
					
				    strVar += "              <tr>";
				    strVar += "                <td>"+u.taskId+"<\/td>\n";
				    strVar += "                <td>"+u.taskExplain+"<\/td>\n";
				    strVar += "                <td>"+u.beginTime+"<\/td>\n";
				    strVar += "                <td>"+u.createTime+"<\/td>\n";
				    strVar += "                <td>"+status+"<\/td>\n";
				    strVar += "                <td>"+grade+"<\/td>\n";
				    strVar += "                <td>"+u.mName+"<\/td>\n";
				    strVar += "                <td>"+u.solution+"<\/td>\n";
				    strVar += "                <td>"+u.remark+"<\/td>\n";
				    strVar += "              <\/tr>";
				    return strVar;
						
                  });
                  $(".print-tbody").html(strVar);
      		//分页
				$("#page").paging({
					pageNo: data.data.list.curPage,
					totalPage: data.data.list.totalPage,
					totalSize: data.data.list.totalRow,
					callback: function(currentPage) {
						ajaxTest(currentPage); 
					}
				});
			},
			error:function(e){
				console.log(e);
			  }
		});
	};
})
//监听浏览器窗口变化
window.onresize = function(){
	var bodyH=$("body").height();
	$(".leftbar").height(bodyH-45+"px");
	$(".content").height(bodyH-45+"px");
	$(".admin").height($(".content").height()-45+"px");
}
//跳转故障详情
$('.print-list li span').click(function(){
	var sid=$('#sid').text();
	window.location.href="printerror.html?sid="+sid;
})

